package cn.buk.tms.dao;

import cn.buk.tms.sc.SearchFlightOrderCriteria;
import cn.buk.tms.entity.misc.OperationLog;
import cn.buk.tms.entity.order.OrderAttachment;
import cn.buk.tms.entity.misc.PaymentMethod;
import cn.buk.tms.entity.misc.Supplier;
import cn.buk.tms.entity.order.flight.FlightChangeOrder;
import cn.buk.tms.entity.order.flight.FlightChangeOrderDetail;

import java.util.Date;
import java.util.List;

public interface FlightChangeOrderDao {

  /**
   * 创建机票改签单
   */
  int createFlightChangeOrder(FlightChangeOrder info);

  List<FlightChangeOrder> searchFlightChangeOrder(int enterpriseId, SearchFlightOrderCriteria sc, List<Integer> allowedCustomerIds);

  FlightChangeOrder getFlightChangeOrderDetail(int id);

  List<OperationLog> searchFlightChangeOrderHistory(int enterpriseId, int id);

  int processFlightChangeOrder(int enterpriseId, String username, int orderId);

  int cancelFlightChangeOrder(int enterpriseId, String username, int orderId, String remark);

  int reopenFlightChangeOrder(int enterpriseId, String username, int orderId);

  int finishFlightChangeOrder(int enterpriseId, String username, int orderId, String pnrNo,
      String ticketNo);

  int updateSupplier(int enterpriseId, String username, int orderId, Supplier supplier);

  int updatePaymentMethod(int enterpriseId, String username, int orderId, PaymentMethod o);

  int updateChangeOrderRemark(int enterpriseId, String username, int orderId, String remark);

  /**
   * 修改改签的票号
   *
   * @param enterpriseId 企业id
   * @param username 用户名
   * @param orderId 订单id
   * @param balanceCode 结算码
   * @param ticketNo 新的10位票号
   */
  int updateChangeOrderTicketNo(int enterpriseId, String username, int orderId, String balanceCode,
      String ticketNo);

  /**
   * 修改改签单的新编码
   */
  void updateChangeOrderNewPnrNo(int enterpriseId, String username, int orderId, String newPnrNo);

  int updateChangeOrderPrice(int enterpriseId, String username, int id, double airChangeCharge,
      double serviceCharge);

  /**
   * 修改改签单的航班信息
   */
  int updateChangeOrderFlightInfo(int enterpriseId, String username, int id,
      FlightChangeOrderDetail detail);

  /**
   * 回滚改签单
   */
  int rollbackChangeOrderStatus(int enterpriseId, String username, int id, final String remark);

  List<FlightChangeOrder> searchUnpaidOrders(int max);

  void setOrderWrittenOff(int enterpriseId, String username, int id, String remark);

  /**
   * 根据机票订单号查找改签单
   */
  List<FlightChangeOrder> searchByFlightOrderNo(final int enterpriseId, final String orderNo);

  /**
   * 查找需要价格校验的改签单
   */
  List<FlightChangeOrder> searchChangeOrdersNeedPriceCheck(final int enterpriseId, Date startDate);

  /**
   * 查找需要刷新DETR信息的改签单
   */
  List<FlightChangeOrder> searchChangeOrdersNeedRefreshDetr(int enterpriseId, int max);

  List<FlightChangeOrder> searchChangeOrdersDetrFinished(int enterpriseId, int max);

  void appendFlightChangeOrderLog(int enterpriseId, int orderId, String username, String content);

  List<FlightChangeOrder> searchMobileIsNull(int enterpriseId);

  void updateChangeOrderMobile(int enterpriseId, String username, int orderId, String mobile);

  void updateChangeOrderDetrStatus(int enterpriseId, String username, int orderId, int status);

  List<FlightChangeOrder> searchChangeOrdersNeedRecheckDetr(int enterpriseId, int max);

  /**
   * 查找需要刷新PNR内容的改签单
   * @param enterpriseId 企业id
   * @param max 返回的最大值
   */
  List<FlightChangeOrder> searchChangeOrdersNeedRefreshPnr(int enterpriseId, int max);

  /**
   * 更新改签单中的PNR待更新状态为完成
   */
  void updateChangeOrderRefreshPnrStatus(int enterpriseId, String username, int orderId);

  /**
   * 更新改期暗淡中的PNR待更新状态为失败
   */
  void updateChangeOrderRefreshPnrStatusFailed(int enterpriseId, String username, int orderId, String remark);

  int saveChangeOrderAttachment(int enterpriseId, String username, int orderId, List<OrderAttachment> attachments);

  List<OrderAttachment> searchAttachments(int enterpriseId, int orderId);

  List<FlightChangeOrder> searchSupplierIsNull(int enterpriseId);

  int updateChangeOrderSupplier(int enterpriseId, String username, int id, Supplier supplier, PaymentMethod paymentMethod);

  int updateExternalOrderNo(int enterpriseId, String username, int orderId, String externalOrderNo, String remark);

  List<FlightChangeOrder> searchWaiting(int enterpriseId, Date startDate);

  /**
   * 根据新编码查找改签单
   * @param enterpriseId 企业id
   * @param pnrNo 新编码
   * @return 符合条件的订单列表
   */
  List<FlightChangeOrder> searchChangeOrderByPnrNo(int enterpriseId, String pnrNo);
}
